package drds.global_transaction.api.message_codec;

import drds.common.ShouldNeverHappenException;
import drds.global_transaction.api.message_codec.request_and_response.register_manager.resource_manager.RegisterResourceManagerRequestMessage;
import drds.global_transaction.api.message_codec.request_and_response.register_manager.resource_manager.RegisterResourceManagerResponseMessage;
import drds.global_transaction.api.message_codec.request_and_response.register_manager.transaction_manager.RegisterTransactionManagerRequestMessage;
import drds.global_transaction.api.message_codec.request_and_response.register_manager.transaction_manager.RegisterTransactionManagerResponseMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.branch_transaction.branch_transaction_end_status_report.branch_transaction_commit_status_report.BranchTransactionCommitRequestMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.branch_transaction.branch_transaction_end_status_report.branch_transaction_commit_status_report.BranchTransactionCommitResponseMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.branch_transaction.branch_transaction_end_status_report.branch_transaction_rollback_status_report.BranchTransactionRollbackRequestMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.branch_transaction.branch_transaction_end_status_report.branch_transaction_rollback_status_report.BranchTransactionRollbackResponseMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.branch_transaction_register.BranchTransactionRegisterRequestMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.branch_transaction_register.BranchTransactionRegisterResponseMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.branch_transaction_status_report.BranchTransactionStatusReportRequestMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.branch_transaction_status_report.BranchTransactionStatusReportResponseMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.global_transaction_begin.GlobalTransactionBeginRequestMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.global_transaction_begin.GlobalTransactionBeginResponseMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.global_transaction_end_status_report.GlobalTransactionStatusReportRequestMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.global_transaction_end_status_report.GlobalTransactionStatusReportResponseMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.global_transaction_end_status_report.global_transaction_commit_status_report.GlobalTransactionCommitRequestMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.global_transaction_end_status_report.global_transaction_commit_status_report.GlobalTransactionCommitResponseMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.global_transaction_end_status_report.global_transaction_rollback_status_report.GlobalTransactionRollbackRequestMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.global_transaction_end_status_report.global_transaction_rollback_status_report.GlobalTransactionRollbackResponseMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.global_transaction_lock_record_ids_check.GlobalTransactionLockRecordIdsCheckRequestMessage;
import drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.global_transaction_lock_record_ids_check.GlobalTransactionLockRecordIdsCheckResponseMessage;

public class MessageCodecs
{
	public static IMessageCodec getMessageCodec(short typeCode)
	{

		switch (typeCode)
		{
		case Message.type_request_messages:
			return new RequestMessages();
		case Message.type_response_messages:
			return new ResponseMessages();
		// 1
		case Message.register_transaction_manager_request_message:
			return new RegisterTransactionManagerRequestMessage();
		case Message.register_transaction_manager_response_message:
			return new RegisterTransactionManagerResponseMessage();
		//
		case Message.register_resource_manager_request_message:
			return new RegisterResourceManagerRequestMessage();
		case Message.register_resource_manager_response_message:
			return new RegisterResourceManagerResponseMessage();
		// 2
		case Message.global_transaction_begin_request_message:
			return new GlobalTransactionBeginRequestMessage();
		case Message.global_transaction_begin_response_message:
			return new GlobalTransactionBeginResponseMessage();
		//
		case Message.global_transaction_commit_request_message:
			return new GlobalTransactionCommitRequestMessage();
		case Message.global_transaction_commit_response_message:
			return new GlobalTransactionCommitResponseMessage();

		//
		case Message.global_transaction_rollback_request_message:
			return new GlobalTransactionRollbackRequestMessage();
		case Message.global_transaction_rollback_response_message:
			return new GlobalTransactionRollbackResponseMessage();
		//
		case Message.global_transaction_status_report_request_message:
			return new GlobalTransactionStatusReportRequestMessage();
		case Message.global_transaction_status_report_response_message:
			return new GlobalTransactionStatusReportResponseMessage();
		//
		case Message.global_transaction_lock_record_ids_check_request_message:
			return new GlobalTransactionLockRecordIdsCheckRequestMessage();
		case Message.global_transaction_lock_record_ids_check_response_message:
			return new GlobalTransactionLockRecordIdsCheckResponseMessage();

		// 3
		case Message.branch_transaction_register_request_message:
			return new BranchTransactionRegisterRequestMessage();
		case Message.branch_transaction_register_response_message:
			return new BranchTransactionRegisterResponseMessage();
		//
		case Message.branch_transaction_commit_request_message:
			return new BranchTransactionCommitRequestMessage();
		case Message.branch_transaction_commit_response_message:
			return new BranchTransactionCommitResponseMessage();
		//
		case Message.branch_transaction_rollback_request_message:
			return new BranchTransactionRollbackRequestMessage();
		case Message.branch_transaction_rollback_response_message:
			return new BranchTransactionRollbackResponseMessage();
		//
		case Message.branch_transaction_status_report_request_message:
			return new BranchTransactionStatusReportRequestMessage();
		case Message.branch_transaction_status_report_response_message:
			return new BranchTransactionStatusReportResponseMessage();
		//
		default:
			throw new ShouldNeverHappenException();
		}
	}

}
